#!/usr/bin/env python
import webapp2

from webapp2_extras import routes



from lib.handlers.overview import OverviewPage
from lib.handlers.admin import AdminRedirect
from lib.handlers.error import ErrorPage
from lib.handlers.signup import SignupPage
from lib.handlers.add import AddPage
from lib.handlers.edit import EditPage
from lib.handlers.settings import SettingsPage
from lib.handlers.faq import FaqPage
from lib.handlers.disclaimer import DisclaimerPage
from lib.handlers.contact import ContactPage
from lib.monitor import Monitor 

PAGE_RE = r'((?:[a-zA-Z0-9_-]+/?)*)'

app = webapp2.WSGIApplication([

    routes.DomainRoute('admin.*.fr',[webapp2.Route('/',handler=AdminRedirect,name='Admin')]),

    ('/admin' + PAGE_RE, AdminRedirect),

    ('/login' + PAGE_RE, OverviewPage),

    ('/signup' + PAGE_RE, SignupPage),

    ('/logout' + PAGE_RE, OverviewPage),

    ('/add' + PAGE_RE, AddPage),

    ('/remove' + PAGE_RE, OverviewPage),

    ('(/404)' + PAGE_RE, ErrorPage),

	('/edit' + PAGE_RE, EditPage),

    ('/settings' + PAGE_RE, SettingsPage),

    ('/faq' + PAGE_RE, SettingsPage),

    ('/disclaimer' + PAGE_RE, DisclaimerPage),

    ('/contact' + PAGE_RE, ContactPage),

    ('/mon', Monitor),

	('/' + PAGE_RE, OverviewPage),

], debug = True)